<!DOCTYPE html>
<meta charset="UTF-8">
<div style="width: 50%;margin: 0 auto; text-align:center; padding: 70px;">
	<form class="layui-form" action="changePwd" method="post" lay-filter="changePwdForm">
	  <div class="layui-form-item">
	    <label class="layui-form-label">原密码</label>
	    <div class="layui-input-block">
	      <input type="password" name="oldPwd" required  lay-verify="required" placeholder="请输入原密码" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">新密码</label>
	    <div class="layui-input-block">
	      <input type="password" name=newPwd id="newPwd" required lay-verify="required|pwdConfirm" placeholder="请输入密码" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">确认密码</label>
	    <div class="layui-input-block">
	      <input type="password" name="newPwd2" id="newPwd2"required lay-verify="required" placeholder="请确认密码" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item" style="text-align: right;">
		  <button type="submit"class="layui-btn"  lay-submit lay-filter="changePwdForm1">修改密码</button> 
		  <button type="reset" class="layui-btn layui-btn-primary">重置</button>
	  </div>
	</form>

</div>
<script type="text/javascript">
layui.use('form',function(){
	form=layui.form;
		form.verify({
			pwdConfirm:function(value,item){
				if($('#newPwd2').val()!=$('#newPwd').val()){
					$('#newPwd').val('');
					$('#newPwd2').val('');
					return "两次输入的新密码不一致，请重新输入";
				}
			}
		});
	    form.on('submit(changePwdForm1)', function(data){
	        $.post('changepwd',data.field,function(result){
	        	if(result.success){
	        		window.location.href="logout";
	        	}else{
	        		layer.alert(result.msg);
	        	}
	        });
	       return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
	      });
	});	
</script>